#!/usr/bin/env node

const http = require('http'),
  url = require('url'),
  qs = require('querystring');

http.createServer((req,res)=>{
  console.log('HTTP request URL:',req.url);

  parseURL('http://wangding:123@www.baidu.com:8080/a/b/c?age=20&gender=M#/d/e/f');
  res.end('OK');
}).listen(8080);

function parseURL(strURL){
  const path = url.parse(strURL);

  console.log('href:',path.href);
  console.log('protocol:',path.protocol);
  console.log('auth:',path.auth);
  console.log('hostname:',path.hostname);
  console.log('port:',path.port);
  console.log('pathname:',path.pathname);
  console.log('search:',path.search);
  console.log('query:',path.query);
  console.log('hash:',path.hash);
  //console.log('authorization',path.authorization);

  console.log('URL parse:',path.pathname.split('/'));
  console.log('QueryString parse:',qs.parse(path.query));

}


